package fr.labri.macchiato.client;

import java.util.HashSet;
import java.util.Set;


import fr.labri.macchiato.core.api.Finder;
import fr.labri.macchiato.core.api.Repository;
import fr.labri.macchiato.core.model.Project;
import fr.labri.macchiato.core.model.UserPreferences;
import fr.labri.macchiato.core.service.BusinessEntityService;
import fr.labri.macchiato.core.service.PreferencesService;
import fr.labri.macchiato.core.service.ProjectService;
import fr.labri.macchiato.core.service.Services;
import fr.labri.macchiato.core.technical.TransientRepository;
import fr.labri.macchiato.feature.distantAccess.RestProductFinder;
import fr.labri.macchiato.feature.googleShopping.GoogleProductsFinder;
import fr.labri.macchiato.feature.localDatabase.SparqlProductFinder;

public class ConfigReader {

	public static Set<Finder> productFinders = new HashSet<Finder>();
	public static Repository<UserPreferences, String> preferencesService;
	
	
	public static void includeServices() {	
		productFinders.add(new SparqlProductFinder("Macchiato.n3", "localDatabase", "http://devnet.superoffice.com/PageFiles/7151/Travel.png"));
		productFinders.add(new RestProductFinder("http://macchiato.fr/Carrefour/query", "Carrefour-Macch", "http://www.transnationale.org/upload/carrefour3.gif"));
		productFinders.add(new RestProductFinder("http://macchiato.fr/Fly/query", "Fly-Macch", "http://www.fly.fr/skin/frontend/fly_fr/default/images/header/logo_1.png"));
		productFinders.add(new GoogleProductsFinder("https://www.googleapis.com/shopping/search/v1/public/products?", "Google", "http://static.commentcamarche.net/www.commentcamarche.net/faq/images/14175-google-logo-3-s-.png"));
	
		preferencesService = new TransientRepository<UserPreferences, String>();
	}
	
	
	public static void init() {	
		includeServices();
		
		Services.getInstance().setPreferencesService(new PreferencesService(preferencesService));
		Services.getInstance().setProjectService(new ProjectService(new TransientRepository<Project, String>(),Services.getInstance().getPreferencesService(), productFinders));
		Services.getInstance().setProductFinders(productFinders);
		Services.getInstance().setBusinessEntityService(new BusinessEntityService(productFinders));
	}
}
